﻿using LJX.SmartPark.Common.ResponseOutput;
using LJX.SmartPark.Domain.Area;
using LJX.SmartPark.Service.Area;
using LJX.SmartPark.Service.Area.Dto;
using LJX.SmartPark.Service.Area.Monitor;
using LJX.SmartPark.Service.Area.Recharge;
using LJX.SmartPark.Service.Area.Recharge.Dto;
using LJX.SmartPark.Service.Area.SchedulSer;
using LJX.SmartPark.Service.Area.SchedulSer.Dto;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace LJX.SmartPark.WebApi.Controllers.Area
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    [ApiExplorerSettings(GroupName = "Area")]
    public class AreaController : ControllerBase
    {
        //排班管理1
        private readonly IScheduleServerice _scheduleServerice;

        //监看监控
        private readonly IMonitoringServeice _monitoringServeice;

        //充电记录
        private readonly IRechargeService _rechargeService;

        // 车辆管理
        private readonly ICarService _carService;

        //临停缴费
        private readonly IProvisionalPayService _provisionalPayService;

        public AreaController(IScheduleServerice scheduleServerice, IMonitoringServeice monitoringServeice, IRechargeService rechargeService, ICarService carService, IProvisionalPayService provisionalPayService)
        {
            _scheduleServerice = scheduleServerice;
            _monitoringServeice = monitoringServeice;
            _rechargeService = rechargeService;
            _carService = carService;
            _provisionalPayService = provisionalPayService;
        }

        #region 排班管理

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public Response<List<Schedule>> GetScheduleServericeAsync(model model)
        {
            var result = _scheduleServerice.GetScheduleServerice(model);
            return result.Result;
        }

        #endregion

        #region 健康监控

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public Response<List<Monitoring>> GetMonitoringAsync()
        {
            var result = _monitoringServeice.GetMonitoring();
            return result.Result;
        }


        #endregion

        #region 充电记录

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public Response<List<RechargeRecord>> GetRechargeAsync(RQuery query)
        {
            var result = _rechargeService.GetRechargeAsync(query);
            return result.Result;
        }

        #endregion

        #region 车辆管理

        /// <summary>
        /// 添加车辆
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        public Task<Response<bool>> PostAddCar(Car input)
        {
            var result = _carService.PostAddCar(input);
            return result;
        }

        /// <summary>
        /// 删除车辆
        /// </summary>
        /// <param name="input"></param>
        [HttpDelete]
        public Task<Response<bool>> DeleteById(Car input)
        {
            var result = _carService.DeleteByIdAsync(input);
            return result;
        }

        /// <summary>
        /// 批量删除车辆
        /// </summary>
        /// <param name="input"></param>
        [HttpDelete]
        public Task<Response<bool>> DeleteAll(params Car[] input)
        {
            var result = _carService.DeleteAllAsync(input);
            return result;
        }

        /// <summary>
        /// 修改车辆
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPut]
        public Task<Response<bool>> PutUpdateCar(Car input)
        {
            var result = _carService.PutUpdateCar(input);

            return result;

        }



        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public Response<List<Car>> GetCarAsync(CarForm car)
        {
            var result = _carService.GetCarAsync(car);
            return result.Result;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        public Response<Car> GetCarById(Car input)
        {
            var student = _carService.GetCarById(input);
            return student;
        }

        #endregion

        #region 临停缴费

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public Response<List<ProvisionalPay>> GetProvisionalPayAsync(ProvisionalPayForm car)
        {
            var result = _provisionalPayService.GetProvisionalPayAsync(car);
            return result.Result;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        public Response<ProvisionalPay> GetProvisionalPayById(ProvisionalPay input)
        {
            var student = _provisionalPayService.GetProvisionalPayById(input);
            return student;
        }

        #endregion

    }
}
